/*    */ package com.zimbra.cs.account.ldap;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.ldap.LdapUtil;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class SpecialAttrs
/*    */ {
/*    */   public static final String SA_zimbraId = "zimbraId";
/*    */   public static final String PA_ldapBase = "ldap.baseDN";
/*    */   private String mZimbraId;
/*    */   private String mLdapBaseDn;
/*    */   
/* 36 */   public String getZimbraId() { return this.mZimbraId; }
/* 37 */   public String getLdapBaseDn() { return this.mLdapBaseDn; }
/*    */   
/*    */   public static String getSingleValuedAttr(Map<String, Object> attrs, String attr) throws ServiceException {
/* 40 */     Object value = attrs.get(attr);
/* 41 */     if (value == null) {
/* 42 */       return null;
/*    */     }
/* 44 */     if (!(value instanceof String)) {
/* 45 */       throw ServiceException.INVALID_REQUEST(attr + " is a single-valued attribute", null);
/*    */     }
/* 47 */     return (String)value;
/*    */   }
/*    */   
/*    */   public void handleZimbraId(Map<String, Object> attrs) throws ServiceException {
/* 51 */     String zimbraId = getSingleValuedAttr(attrs, "zimbraId");
/*    */     
/* 53 */     if (zimbraId != null)
/*    */     {
/*    */       try {
/* 56 */         if (!LdapUtil.isValidUUID(zimbraId))
/* 57 */           throw ServiceException.INVALID_REQUEST(zimbraId + " is not a valid UUID", null);
/*    */       } catch (IllegalArgumentException e) {
/* 59 */         throw ServiceException.INVALID_REQUEST(zimbraId + " is not a valid UUID", e);
/*    */       }
/*    */       
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/* 75 */       attrs.remove("zimbraId");
/* 76 */       this.mZimbraId = zimbraId;
/*    */     }
/*    */   }
/*    */   
/*    */   public void handleLdapBaseDn(Map<String, Object> attrs) throws ServiceException {
/* 81 */     String baseDn = getSingleValuedAttr(attrs, "ldap.baseDN");
/* 82 */     if (baseDn != null) {
/* 83 */       attrs.remove("ldap.baseDN");
/* 84 */       this.mLdapBaseDn = baseDn;
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/SpecialAttrs.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */